import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login'
import Layout from "@/views/Layout"
import Home from "@/views/Home"
import User from "@/views/User"
import Search from '@/views/Search'
import SearchResult from '@/views/Search/SearchResult.vue'
import ArticleDelail from '@/views/ArticleDelail'

Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: '/layout/home' //默认显示layout和layout下首页
  },
  { //登录
    path: '/login',
    component: Login
  },
  {
    path: '/layout',
    component: Layout,
    children: [{ //首页
        path: 'home',
        component: Home
      },
      { //我的
        path: 'user',
        component: User
      },
    ]
  },
  { //搜索页
    path: '/search',
    component: Search
  },
  { //搜索结果页
    path: '/search_result/:kw',
    component: SearchResult
  },
  { //文章详情
    path: '/delail',
    component: ArticleDelail
  },
]

const router = new VueRouter({
  routes
})

export default router